<?php
	$query = "select * from forum_posts order by `time` desc limit 5";
	$result = mysql_query($query);
	if ($result) {
		while ($post = mysql_fetch_array($result)) {
			$query2 = "select * from `forum_threads` where `id`='".$post['parent']."'";
			$result2 = mysql_query($query2);
			if ($result2) {
				$thread = mysql_fetch_array($result2);
				$query3 = "select `time` from `forum_posts` where `id` ='".$post['id']."'";
				$result3 = mysql_query($query3);
				$post2 = mysql_fetch_array($result3);
				$time = date("d-m-Y H:i:s",$post2['time']);
				$title = GetLangString($lang,"forum_title".$thread['parent']) ;
				$query4 = "select * from `users` where `id` = '".$post['user']."'";
				$result4 = mysql_query($query4);
				$userinfo = mysql_fetch_array($result4);
				$poster = $userinfo['name'];
				
				$threads .= FormatLink(	 bb2html($thread['name'])  ,$time . " in ". $title . " by " . $poster, "index.php?do=forum&thread=".$post['parent']);
			} 
			
		}
	} 
	
	$SITE_MIDDLE .= FormatElement( GetLangString ($lang, "txt_forumtop5") , $threads ) ;

?>